package com.atguigu.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Auther: fangshicai
 * @Date: 2022/1/23 22:30
 * @Description: InitializingBean可以在注入完成后实行afterPropertiesSet()方法
 */
@Component
public class ConstantPropertiesUtil implements InitializingBean {

    //@Value可以从application.properties文件之中注入值
    @Value("${aliyun.oss.file.endpoint}")
    private String endPoint;

    @Value("${aliyun.oss.file.keyid}")
    private String keyId;

    @Value("${aliyun.oss.file.keysecret}")
    private String keySecret;

    @Value("${aliyun.oss.file.bucketname}")
    private String bucketName;

    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT=this.endPoint;
        ACCESS_KEY_ID=this.keyId;
        ACCESS_KEY_SECRET=this.keySecret;
        BUCKET_NAME=this.bucketName;
    }
}
